﻿/*
 * Configuration
 * 
 * Author: snowdreamist
 * Date: 2011/11/22
 * 
 */

using System;
using System.Collections.Generic;
using System.Net;
using System.Linq;
using System.Text;
using System.Configuration;

namespace BitTorrentSharp.DHT
{
    /// <summary>
    /// DHT Configuraion Section
    /// </summary>
    public class DHTConfigurationSection : ConfigurationSection
    {
        /// <summary>
        /// Routing config
        /// </summary>
        public RoutingConfiguration Routing
        {
            get
            {
                return (RoutingConfiguration)base["routing"];
            }
        }
        /// <summary>
        /// Network
        /// </summary>
        public NetworkConfiguration Network
        {
            get
            {
                return (NetworkConfiguration)base["network"];
            }
        }
    }

    /// <summary>
    /// Routing configuration
    /// </summary>
    public class RoutingConfiguration : ConfigurationElement
    {
        /// <summary>
        /// node config
        /// </summary>
        public NodeConfiguration Node
        {
            get
            {
                return (NodeConfiguration)base["node"];
            }
        }
        /// <summary>
        /// bucket config
        /// </summary>
        public BucketConfiguration Bucket
        {
            get
            {
                return (BucketConfiguration)base["bucket"];
            }
        }
    }

    /// <summary>
    /// Bucket configuration
    /// </summary>
    public class BucketConfiguration : ConfigurationElement
    {
        /// <summary>
        /// Max size
        /// </summary>
        public int MaxSize { get; set; }
        /// <summary>
        /// Refresh interval
        /// </summary>
        public TimeSpan RefreshInterval { get; set; }
    }

    /// <summary>
    /// Node configuration
    /// </summary>
    public class NodeConfiguration : ConfigurationElement
    {
        /// <summary>
        /// Good node time out time
        /// </summary>
        public TimeSpan TimeOut { get; set; }
    }

    /// <summary>
    /// network configuration
    /// </summary>
    public class NetworkConfiguration : ConfigurationElement
    {
        /// <summary>
        /// Get listening port
        /// </summary>
        public int Port { get; set; }
    }
}